//
//  BPHomePageViewController.m
//  Translation
//
//  Created by mac on 17/3/6.
//  Copyright © 2017年 Mephsito. All rights reserved.
//

#import "BPHomePageViewController.h"
#import "BPHomepageViewModel.h"
#import "MRCNavigationController.h"

#import "ScheduleViewController.h"
#import "ContactsViewController.h"
#import "YunViewController.h"

#import "AppDelegate.h"



@interface BPHomePageViewController ()
@property (nonatomic, strong)BPHomepageViewModel *viewModel;

@end

@implementation BPHomePageViewController

@dynamic viewModel;

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tabbarView.btnSelct = ^BOOL(UIButton *btn) {
        return YES;
    };
    
    UINavigationController *OneNavigationController = ({
        ScheduleViewController *OneViewController = [[ScheduleViewController alloc] initWithViewModel:self.viewModel.oneViewModel];
        
        UIImage *image=[UIImage imageNamed:@"richeng-01"];
        NSLog(@"%@",image);
        
        OneViewController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"日程"
                                                                     image:[UIImage imageNamed:@"home01"]
                                                             selectedImage:[UIImage imageNamed:@"home02"]];
        //设置tabbar按钮
        [self.tabbarView addTabbarButton:OneViewController.tabBarItem];
        
        [[MRCNavigationController alloc] initWithRootViewController:OneViewController];
    });
    
    
    
    UINavigationController *TwoNavigationController = ({
        ContactsViewController *TwoViewController = [[ContactsViewController alloc] initWithViewModel:self.viewModel.twoVIewModel];
        
        TwoViewController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"联系人"
                                                                     image:[UIImage imageNamed:@"lianxiren-1"]
                                                             selectedImage:[UIImage imageNamed:@"lianxiren-2"]];
        
         [self.tabbarView addTabbarButton:TwoViewController.tabBarItem];
        
        [[MRCNavigationController alloc] initWithRootViewController:TwoViewController];
    });
    
    UINavigationController *ThreeNavigationController = ({
        YunViewController *threeViewController = [[YunViewController alloc] initWithViewModel:self.viewModel.threeViewModel];
        
        
        threeViewController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"云盘"
                                                                     image:[UIImage imageNamed:@"richeng-1"]
                                                             selectedImage:[UIImage imageNamed:@"richeng-2"]];
        
        [self.tabbarView addTabbarButton:threeViewController.tabBarItem];
        [[MRCNavigationController alloc] initWithRootViewController:threeViewController];
    });
    

   self.tabBarController.viewControllers = @[ OneNavigationController, TwoNavigationController, ThreeNavigationController];
   
    [BPSharedAppDelegate.navigationControllerStack pushNavigationController:OneNavigationController];
    
    
    [[self
      rac_signalForSelector:@selector(tabbarButton:from:to:)
      fromProtocol:@protocol(XZmytabbarDelegate)]
     subscribeNext:^(RACTuple *tuple) {
         
         NSNumber *index=tuple.third;
         UINavigationController *nav=self.tabBarController.viewControllers[index.integerValue];
         [self.tabBarController setSelectedIndex:index.integerValue];
         
         [BPSharedAppDelegate.navigationControllerStack popNavigationController];
         [BPSharedAppDelegate.navigationControllerStack pushNavigationController:nav];
     }];
}

@end
